//index.js
import Toast from './kb-test-toast.vue';

let ToastPlugin = {};

ToastPlugin.install = function (Vue, options) {
  const ToastConstructor = Vue.extend(Toast);
  let ToastInstance = new (ToastConstructor);
  const div = document.createElement('div');
  ToastInstance.$mount(div);
  document.body.appendChild(ToastInstance.$el);

  console.log('kb-test-toast options: ', options)

  Vue.prototype.$toast = function (msg, duration = 2000) {
    ToastInstance.message = msg;
    ToastInstance.show = true;
    setTimeout(() => {
      ToastInstance.show = false
    }, duration)
  }
}
export default ToastPlugin
